#! -*- coding: utf-8 -*-
import os
import datetime
from io import BytesIO

import jwt
import pandas as pd
from sqlalchemy import func, or_, and_
from flask import request, jsonify, current_app, send_file, send_from_directory

from config import base_config, log_config
from .models import (
    CdcAccessInfo,
    CdcUserInfo,
    CdcBaseInfo,
    CdcResumeInfo,
    CdcActivityInfo,
    CdcBackgroundInfo,
    CdcInternshipInfo,
    CdcOfferInfo,
    CdcKeyInfo,
    CdcGraduateInfo,
    CdcDailyInfo,
    CdcIsGraduateRegisteReport,
    CdcIsProvinceSystemReport,
    CdcIsParentsContacted,
    CdcIsDifficultyType,
    CdcIsApecialAttention,
    CdcIsOfferState,
    CdcIsEntranceYear,
    CdcIsProjectType,
    CdcIsChineseLevel,
    CdcIsOfferType,
    CdcIsGraduatePlan,
    CdcSchoolProgramArea
)


class CdcCareer:

    def __init__(self):
        self.session = current_app.config["ENGINES"]["sme_cdc_career"]
        self.resume_path = "/mnt/nas-ex/team_data/cdc/cdc_career/resume_data"
        self.logger = log_config.generate_logger(
            base_config.SME_CDC_CAREER["INFO_LOG_PATH"], 
            base_config.SME_CDC_CAREER["WARN_LOG_PATH"], 
            base_config.SME_CDC_CAREER["ERROR_LOG_PATH"]
        )

    def login(self):
        try:
            f_username = request.json.get("username", str())
            f_password = request.json.get("password", str())
            self.logger.info(f"[{request.request_id}] username: {f_username}, password: {f_password}")
            query = self.session.query(CdcUserInfo).filter(CdcUserInfo.f_username == f_username, CdcUserInfo.f_password == f_password)
            obj = query.first()
            if not obj:
                self.logger.warning(f"[{request.request_id}] 用户名或密码错误")
                return jsonify({"code": 400, "msg": "用户名或密码错误", "data": {}})
            obj.f_token = jwt.encode(
                {
                    "username": obj.f_username,
                    "password": obj.f_password,
                    "exp": datetime.datetime.now() + datetime.timedelta(hours=24),
                },
                base_config.SECRET_KEY,
                algorithm="HS256",
            )
            obj.f_update = datetime.datetime.now()
            self.session.commit()
            self.logger.info(f"[{request.request_id}] 登录成功")
            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": {
                        "uid": str(obj.id),
                        "token": str(obj.f_token),
                        "access_id": str(obj.f_access_id),
                        "access_name": str(obj.f_access_name),
                        "display_name": str(obj.f_display_name),
                    },
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def logout(self):
        try:
            f_uid = request.json.get("uid", str())
            f_token = request.json.get("token", str())
            query = self.session.query(CdcUserInfo).filter(CdcUserInfo.id == f_uid, CdcUserInfo.f_token == f_token)
            obj = query.first()
            obj.f_token = "N/A"
            obj.f_update = datetime.datetime.now()
            self.session.commit()
            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": {},
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def main_search(self):
        try:
            f_uid = request.json.get("uid", str())
            f_sid = request.json.get("sid", str())
            f_page = request.json.get("page", str())
            f_limit = request.json.get("limit", str())
            f_name = request.json.get("name", str())
            f_major = request.json.get("major", str())
            f_graduation_year = request.json.get("graduation_year", int())
            f_state = request.json.get("state", str())
            f_partner = request.json.get("partner", str())
            f_difficulty = request.json.get("difficulty", str())
            f_state = request.json.get("state", str())
            f_dict = {
                "f_sid": f_sid,
                "f_name": f_name,
                "f_major": f_major,
                "f_graduation_year": datetime.datetime.fromtimestamp(int(f_graduation_year)).strftime("%Y") if f_graduation_year else "",
                "f_state": f_state,
                "f_partner": f_partner,
            }
            non_empty_fields = { key:value for key,value in f_dict.items() if isinstance(value, str) and value.strip() != "" }
            query = self.session.query(
                CdcBaseInfo, CdcKeyInfo, CdcBackgroundInfo
            ).join(
                CdcKeyInfo, CdcBaseInfo.f_sid == CdcKeyInfo.f_sid
            ).join(
                CdcBackgroundInfo, CdcBaseInfo.f_sid == CdcBackgroundInfo.f_sid
            )
            for key, value in non_empty_fields.items():
                query = query.filter(getattr(CdcBaseInfo, key).like(f"%{value}%"))
            if f_difficulty == "Y":
                query = query.filter(and_(
                    CdcKeyInfo.f_difficulty_type.isnot(None),
                    CdcKeyInfo.f_difficulty_type != "",
                    CdcKeyInfo.f_difficulty_type != "N/A",
                ))
            if f_difficulty == "N":
                query = query.filter(or_(
                    CdcKeyInfo.f_difficulty_type.is_(None),
                    CdcKeyInfo.f_difficulty_type == "",
                    CdcKeyInfo.f_difficulty_type == "N/A",
                ))
            total = query.count()
            query = query.limit(int(f_limit)).offset((int(f_page) - 1) * int(f_limit))
            objs = query.all()
            res_data = list()
            _seq = 0
            for obj in objs:
                _seq += 1
                res_data.append({
                    "seq": str(_seq),
                    "record_id": str(obj.CdcBaseInfo.id),
                    "sid": str(obj.CdcBaseInfo.f_sid),
                    "name": str(obj.CdcBaseInfo.f_name),
                    "major": str(obj.CdcBaseInfo.f_major),
                    "approach": str(obj.CdcBaseInfo.f_approach),
                    "graduation_year": str(obj.CdcBaseInfo.f_graduation_year),
                    "graduate_plan": str(obj.CdcBackgroundInfo.f_graduate_plan),
                    "cgpa": str(obj.CdcBaseInfo.f_cgpa),
                    "phone": str(obj.CdcBaseInfo.f_phone),
                    "partner": str(obj.CdcBaseInfo.f_partner),
                    "is_difficulty": "Y" if obj.CdcKeyInfo.f_difficulty_type not in ["", "N/A"] else "N",
                    "is_offer": "Y" if self.session.query(CdcOfferInfo).filter(CdcOfferInfo.f_sid == CdcBaseInfo.f_sid).count() else "N"
                })
            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": {
                        "total": total,
                        "detail": res_data
                    }
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def main_upload(self):
        try:
            # if "file" not in request.files:
            #     return jsonify({"code": 400, "msg": "未上传文件", "data": dict()})
            # file = request.files["file"]
            # if file.filename == "" or not file.filename.endswith(".xlsx"):
            #     return jsonify({"code": 400, "msg": "请选择有效的 XLSX 文件", "data": dict()})
            # df = pd.read_excel(file)
            # for index, row in df.iterrows():
            #     if index < 2:
            #         continue
            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": {},
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def main_template_download(self):
        try:
            return send_from_directory(
                os.path.join(current_app.root_path, "object/templates/ID_sme/cdc_career"),
                "基础信息-模板.xlsx",
                as_attachment=True,
                download_name="BaseTemplate.xlsx"
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def main_download(self):
        try:
            f_uid = request.json.get("uid", str())
            f_sid = request.json.get("sid", str())
            f_name = request.json.get("name", str())
            f_college = request.json.get("college", str())
            f_major = request.json.get("major", str())
            f_grade = request.json.get("grade", str())
            f_graduation_pre = request.json.get("graduation_pre", str())
            f_graduation_year = request.json.get("graduation_year", str())
            f_phone = request.json.get("phone", str())
            f_email = request.json.get("email", str())
            f_state = request.json.get("state", str())
            f_cgpa = request.json.get("cgpa", str())
            f_dict = {
                "f_sid": f_sid,
                "f_name": f_name,
                "f_college": f_college,
                "f_major": f_major,
                "f_grade": f_grade,
                "f_graduation_pre": func.from_unixtime(f_graduation_pre),
                "f_graduation_year": f_graduation_year,
                "f_phone": f_phone,
                "f_email": f_email,
                "f_state": f_state,
                "f_cgpa": f_cgpa,
            }
            non_empty_fields = { key:value for key,value in f_dict.items() if isinstance(value, str) and value.strip() != "" }
            query = self.session.query(CdcBaseInfo).filter_by(**non_empty_fields)
            objs = query.all()
            res_data = list()
            _seq = 0
            for obj in objs:
                _seq += 1
                res_data.append({
                    "seq": str(_seq),
                    "record_id": str(obj.id),
                    "sid": str(obj.f_sid),
                    "name": str(obj.f_name),
                    "college": str(obj.f_college),
                    "major": str(obj.f_major),
                    "grade": str(obj.f_grade),
                    "graduation_pre": str(int(obj.f_graduation_pre.timestamp())) if obj.f_graduation_pre else "",
                    "graduation_year": str(obj.f_graduation_year),
                    "phone": str(obj.f_phone),
                    "email": str(obj.f_email),
                    "academic_advisor": str(obj.f_academic_advisor),
                    "academic_advisor_phone": str(obj.f_academic_advisor_phone),
                    "state": str(obj.f_state),
                    "emergency_contact": str(obj.f_emergency_contact),
                    "emergency_contact_phone": str(obj.f_emergency_contact_phone),
                    "cgpa": str(obj.f_cgpa),
                    "credit": str(obj.f_credit),
                    "approach": str(obj.f_approach),
                    "warn_info": str(obj.f_warn_info),
                })
            df = pd.DataFrame(res_data)
            output = BytesIO()
            with pd.ExcelWriter(output, engine="xlsxwriter") as writer:
                df.to_excel(writer, sheet_name="Download", index=False)
            output.seek(0)
            return send_file(output, as_attachment=True, mimetype="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", download_name="Export.xlsx")
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def main_add(self):
        try:
            f_uid = request.json.get("uid", str())
            f_sid = request.json.get("sid", str())
            f_name = request.json.get("name", str())
            f_college = request.json.get("college", str())
            f_major = request.json.get("major", str())
            f_grade = request.json.get("grade", str())
            f_graduate_pre = request.json.get("graduation_pre", str())
            f_graduation_year = request.json.get("graduation_year", str())
            f_phone = request.json.get("phone", str())
            f_email = request.json.get("email", str())
            f_academic_advisor = request.json.get("academic_advisor", str())
            f_academic_advisor_phone = request.json.get("academic_advisor_phone", str())
            f_state = request.json.get("state", str())
            f_emergency_contact = request.json.get("emergency_contact", str())
            f_emergency_contact_phone = request.json.get("emergency_contact_phone", str())
            f_cgpa = request.json.get("cgpa", str())
            f_credit = request.json.get("credit", str())
            f_approach = request.json.get("approach", str())
            f_warn_info = request.json.get("warn_info", str())
            query = self.session.query(CdcBaseInfo).filter(CdcBaseInfo.f_sid == f_sid)
            obj = query.first()
            if obj:
                return jsonify({"code": 400, "msg": "学号已存在", "data": {}})
            base_obj = CdcBaseInfo(
                f_sid=f_sid,
                f_name=f_name,
                f_college=f_college,
                f_major=f_major,
                f_grade=f_grade,
                f_graduation_pre=func.from_unixtime(f_graduate_pre),
                f_graduation_year=f_graduation_year,
                f_phone=f_phone,
                f_email=f_email,
                f_academic_advisor=f_academic_advisor,
                f_academic_advisor_phone=f_academic_advisor_phone,
                f_state=f_state,
                f_emergency_contact=f_emergency_contact,
                f_emergency_contact_phone=f_emergency_contact_phone,
                f_cgpa=f_cgpa,
                f_credit=f_credit,
                f_approach=f_approach,
                f_warn_info=f_warn_info,
            )
            self.session.add(base_obj)
            self.session.commit()
            self.session.flush()
            base_id = base_obj.id
            background_obj = CdcBackgroundInfo(
                f_sid=f_sid,
                f_graduate_plan="N/A",
                f_internship_count="N/A",
                f_internship_company="N/A",
                f_internship_position="N/A",
                f_internship_location="N/A",
                f_consult_count="N/A",
                f_activity_count="N/A",
                f_activity_type="N/A",
                f_activity_name="N/A",
                f_activity_time="N/A",
                f_target_industry="N/A",
                f_target_position="N/A",
                f_target_location="N/A",
                f_target_area="N/A",
                f_target_program="N/A",
                f_ielts="N/A",
                f_toefl="N/A",
                f_gre="N/A",
                f_gmat="N/A",
                f_chinese_level="N/A",
                f_sid_id=base_id
            )
            self.session.add(background_obj)
            self.session.commit()
            activity_obj = CdcActivityInfo(
                f_sid=base_obj.f_sid,
                f_activity_time=datetime.datetime.now(),
                f_activity_type="N/A",
                f_activity_name="N/A",
                f_remark="N/A",
                f_sid_id=base_id
            )
            self.session.add(activity_obj)
            self.session.commit()
            internship_obj = CdcInternshipInfo(
                f_sid = f_sid,
                f_start_time = datetime.datetime.now(),
                f_end_time = datetime.datetime.now(),
                f_company = "N/A",
                f_position = "N/A",
                f_location = "N/A",
                f_sid_id = base_id
            )
            self.session.add(internship_obj)
            self.session.commit()
            offer_obj = CdcOfferInfo(
                f_sid = f_sid,
                f_offer_type = "N/A",
                f_offer_area = "N/A",
                f_company_college_name = "N/A",
                f_position_project_name = "N/A",
                f_entrance_date = datetime.datetime.now(),
                f_industry_name = "N/A",
                f_salary_month = "N/A",
                f_salary_year = "N/A",
                f_accept_status = "N/A",
                f_remark = "N/A",
                f_sid_id = base_id
            )
            self.session.add(offer_obj)
            self.session.commit()
            key_obj = CdcKeyInfo(
                f_sid = f_sid,
                f_apecial_attention = "N/A",
                f_difficulty_type = "N/A",
                f_support_need = "N/A",
                f_support_info = "N/A",
                f_parents_contacted = "N/A",
                f_sid_id = base_id
            )
            self.session.add(key_obj)
            self.session.commit()
            graduate_obj = CdcGraduateInfo(
                f_sid = f_sid,
                f_province_system_report = "N/A",
                f_graduate_registe_report = "N/A",
                f_sid_id = base_id
            )
            self.session.add(graduate_obj)
            self.session.commit()
            daily_obj = CdcDailyInfo(
                f_sid = f_sid,
                f_name = "N/A",
                f_type = "N/A",
                f_time = datetime.datetime.now(),
                f_detail = "N/A",
                f_sid_id = base_id
            )
            self.session.add(daily_obj)
            self.session.commit()

            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": {
                        "sid": f_sid,
                        "record_id": base_id,
                    },
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def main_delete(self):
        try:
            # TODO: 待实现
            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": res,
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def detail_search(self):
        try:
            f_uid = request.json.get("uid", str())
            f_sid = request.json.get("sid", str())
            f_page = request.json.get("page", str())
            f_limit = request.json.get("limit", str())
            base_info, background_info, offer_info, key_info, graduate_info, daily_info = dict(), dict(), dict(), dict(), dict(), dict()
            query = self.session.query(CdcBaseInfo).filter(CdcBaseInfo.id == f_sid)
            obj = query.first()
            if obj is not None:
                base_info = {
                    "sid": str(obj.f_sid),
                    "base_info_id": str(obj.id),
                    "name": str(obj.f_name),
                    "college": str(obj.f_college),
                    "major": str(obj.f_major),
                    "grade": str(obj.f_grade),
                    "graduation_pre": str(int(obj.f_graduation_pre.timestamp())) if obj.f_graduation_pre else "",
                    "graduation_year": str(obj.f_graduation_year),
                    "phone": str(obj.f_phone),
                    "email": str(obj.f_email),
                    "academic_advisor": str(obj.f_academic_advisor),
                    "academic_advisor_phone": str(obj.f_academic_advisor_phone),
                    "state": str(obj.f_state),
                    "emergency_contact": str(obj.f_emergency_contact),
                    "emergency_contact_phone": str(obj.f_emergency_contact_phone),
                    "cgpa": str(obj.f_cgpa),
                    "credit": str(obj.f_credit),
                    "approach": str(obj.f_approach),
                    "warn_info": str(obj.f_warn_info),
                    "partner": str(obj.f_partner),
                }
            query = self.session.query(CdcBackgroundInfo).filter(CdcBackgroundInfo.f_sid == f_sid)
            obj = query.first()
            if obj is not None:
                background_info = {
                    "sid": str(obj.f_sid),
                    "background_info_id": str(obj.id),
                    "graduate_plan": str(obj.f_graduate_plan),
                    "internship_count": str(obj.f_internship_count),
                    "internship_company": str(obj.f_internship_company),
                    "internship_position": str(obj.f_internship_position),
                    "internship_location": str(obj.f_internship_location),
                    "resume_id": str(obj.f_resume_id),
                    "consult_count": str(obj.f_consult_count),
                    "activity_count": str(obj.f_activity_count),
                    "activity_type": str(obj.f_activity_type),
                    "activity_name": str(obj.f_activity_name),
                    "activity_time:": str(int(obj.f_activity_time.timestamp())) if obj.f_activity_time else "",
                    "target_industry": str(obj.f_target_industry),
                    "target_position": str(obj.f_target_position),
                    "target_location": str(obj.f_target_location),
                    "target_area": str(obj.f_target_area),
                    "target_program": str(obj.f_target_program),
                    "ielts": str(obj.f_ielts),
                    "toefl": str(obj.f_toefl),
                    "gre": str(obj.f_gre),
                    "gmat": str(obj.f_gmat),
                    "chinese_level": str(obj.f_chinese_level),
                }
            query = self.session.query(CdcOfferInfo).filter(CdcOfferInfo.f_sid == f_sid)
            obj = query.first()
            if obj is not None:
                offer_info = {
                    "sid": str(obj.f_sid),
                    "offer_info_id": str(obj.id),
                    "offer_state": str(obj.f_offer_state),
                    "offer_area": str(obj.f_offer_area),
                    "college_name": str(obj.f_college_name),
                    "project_name": str(obj.f_project_name),
                    "project_type": str(obj.f_project_type),
                    "company_name": str(obj.f_company_name),
                    "position": str(obj.f_position),
                    "salary_month": str(obj.f_salary_month),
                    "salary_year": str(obj.f_salary_year),
                    "entrance_time": str(int(obj.f_entrance_time.timestamp())) if obj.f_entrance_time else "",
                    "entrance_year": str(obj.f_entrance_year),
                    "state": str(obj.f_state),
                }
            query = self.session.query(CdcKeyInfo).filter(CdcKeyInfo.f_sid == f_sid)
            obj = query.first()
            if obj is not None:
                key_info = {
                    "sid": str(obj.f_sid),
                    "key_info_id": str(obj.id),
                    "apecial_attention": str(obj.f_apecial_attention),
                    "difficulty_type": str(obj.f_difficulty_type),
                    "support_need": str(obj.f_support_need),
                    "support_info": str(obj.f_support_info),
                    "parents_contacted": str(obj.f_parents_contacted),
                }
            query = self.session.query(CdcGraduateInfo).filter(CdcGraduateInfo.f_sid == f_sid)
            obj = query.first()
            if obj is not None:
                graduate_info = {
                    "sid": str(obj.f_sid),
                    "graduate_info_id": str(obj.id),
                    "province_system_report": str(obj.f_province_system_report),
                    "graduate_registe_report": str(obj.f_graduate_registe_report),
                }
            query = self.session.query(CdcDailyInfo).filter(CdcDailyInfo.f_sid == f_sid)
            obj = query.first()
            if obj is not None:
                daily_info = {
                    "sid": str(obj.f_sid),
                    "university_recommend": str(obj.f_university_recommend),
                }
            
            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": {
                        "base_info": base_info,
                        "background_info": background_info,
                        "offer_info": offer_info,
                        "key_info": key_info,
                        "graduate_info": graduate_info,
                        "daily_info": daily_info,
                    },
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def detail_base_info_search(self):
        try:
            f_uid = request.json.get("uid", str())
            f_sid = request.json.get("sid", str())
            f_record_id = request.json.get("record_id", str())
            f_base_info_id = request.json.get("base_info_id", str())
            query = self.session.query(CdcBaseInfo).filter(CdcBaseInfo.f_sid == f_sid)
            obj = query.first()
            res = dict()
            res["base_info_id"] = str(obj.id)
            res["sid"] = str(obj.f_sid)
            res["name"] = str(obj.f_name)
            res["college"] = str(obj.f_college)
            res["major"] = str(obj.f_major)
            res["grade"] = str(obj.f_grade)
            res["graduation_pre"] = str(int(obj.f_graduation_pre.timestamp())) if obj.f_graduation_pre else ""
            res["graduation_year"] = str(obj.f_graduation_year)
            res["phone"] = str(obj.f_phone)
            res["email"] = str(obj.f_email)
            res["academic_advisor"] = str(obj.f_academic_advisor)
            res["academic_advisor_phone"] = str(obj.f_academic_advisor_phone)
            res["state"] = str(obj.f_state)
            res["emergency_contact"] = str(obj.f_emergency_contact)
            res["emergency_contact_phone"] = str(obj.f_emergency_contact_phone)
            res["cgpa"] = str(obj.f_cgpa)
            res["credit"] = str(obj.f_credit)
            res["approach"] = str(obj.f_approach)
            res["warn_info"] = str(obj.f_warn_info)
            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": res,
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def detail_base_info_update(self):
        try:
            f_uid = request.json.get("uid", str())
            f_sid = request.json.get("sid", str())
            f_record_id = request.json.get("record_id", str())
            f_base_info_id = request.json.get("base_info_id", str())
            f_name = request.json.get("name", str())
            f_college = request.json.get("college", str())
            f_major = request.json.get("major", str())
            f_grade = request.json.get("grade", str())
            f_graduation_pre = request.json.get("graduation_pre", str())
            f_graduation_year = request.json.get("graduation_year", str())
            f_phone = request.json.get("phone", str())
            f_email = request.json.get("email", str())
            f_academic_advisor = request.json.get("academic_advisor", str())
            f_academic_advisor_phone = request.json.get("academic_advisor_phone", str())
            f_state = request.json.get("state", str())
            f_emergency_contact = request.json.get("emergency_contact", str())
            f_emergency_contact_phone = request.json.get("emergency_contact_phone", str())
            f_cgpa = request.json.get("cgpa", str())
            f_credit = request.json.get("credit", str())
            f_approach = request.json.get("approach", str())
            f_warn_info = request.json.get("warn_info", str())
            query = self.session.query(CdcBaseInfo).filter(CdcBaseInfo.f_sid == f_sid, CdcBaseInfo.id == f_base_info_id)
            obj = query.first()
            obj.f_name = f_name
            obj.f_college = f_college
            obj.f_major = f_major
            obj.f_grade = f_grade
            obj.f_graduation_pre = func.from_unixtime(f_graduation_pre)
            obj.f_graduation_year = f_graduation_year
            obj.f_phone = f_phone
            obj.f_email = f_email
            obj.f_academic_advisor = f_academic_advisor
            obj.f_academic_advisor_phone = f_academic_advisor_phone
            obj.f_state = f_state
            obj.f_emergency_contact = f_emergency_contact
            obj.f_emergency_contact_phone = f_emergency_contact_phone
            obj.f_cgpa = f_cgpa
            obj.f_credit = f_credit
            obj.f_approach = f_approach
            obj.f_warn_info = f_warn_info
            self.session.commit()
            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": {},
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def detail_background_info_search(self):
        try:
            f_uid = request.json.get("uid", str())
            f_sid = request.json.get("sid", str())
            f_record_id = request.json.get("record_id", str())
            f_background_info_id = request.json.get("background_info_id", str())
            query = self.session.query(CdcBackgroundInfo).filter(CdcBackgroundInfo.f_sid == f_sid)
            obj = query.first()
            resume_query = self.session.query(CdcResumeInfo).filter(CdcResumeInfo.f_sid == f_sid)
            resume_objs = resume_query.all()
            resume_ids = [resume_obj.id for resume_obj in resume_objs]
            res = dict()
            res["uid"] = f_uid
            res["sid"] = str(obj.f_sid)
            res["record_id"] = str(f_record_id)
            res["background_info_id"] = str(obj.id)
            res["resume_id"] = resume_ids
            res["graduation_plan"] = str(obj.f_graduate_plan)
            res["internship_count"] = str(self.session.query(CdcInternshipInfo).filter(CdcInternshipInfo.f_sid == f_sid).count())
            res["counsult_count"] = str(obj.f_consult_count)
            res["activity_count"] = str(self.session.query(CdcActivityInfo).filter(CdcActivityInfo.f_sid == f_sid).count())
            res["target_industry"] = "N/A"
            res["target_area"] = "N/A"
            res["target_program"] = "N/A"
            res["target_position"] = "N/A"
            res["target_location"] = "N/A"
            res["gre"] = str(obj.f_gre)
            res["gmat"] = str(obj.f_gmat)
            res["ielts"] = str(obj.f_ielts)
            res["toefl"] = str(obj.f_toefl)
            res["chinese_level"] = str(obj.f_chinese_level)
            res["intend_area_study_employment"] = str(obj.f_intend_area_study_employment)
            res["intend_industry_position"] = str(obj.f_intend_industry_position)
            res["intend_school_program"] = str(obj.f_intend_school_program)
            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": res,
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def detail_background_info_update(self):
        try:
            f_uid = request.json.get("uid", str())
            f_sid = request.json.get("sid", str())
            f_record_id = request.json.get("record_id", str())
            f_background_info_id = request.json.get("background_info_id", str())
            f_graduate_plan = request.json.get("graduation_plan", str())
            f_target_industry = request.json.get("target_industry", str())
            f_target_area = request.json.get("target_area", str())
            f_target_program = request.json.get("f_target_program", str())
            f_target_position = request.json.get("target_position", str())
            f_target_location = request.json.get("target_location", str())
            f_gre = request.json.get("gre", str())
            f_gmat = request.json.get("gmat", str())
            f_ielts = request.json.get("ielts", str())
            f_toefl = request.json.get("toefl", str())
            f_chinese_level = request.json.get("chinese_level", str())
            f_intend_area_study_employment = request.json.get("intend_area_study_employment", str())
            f_intend_industry_position = request.json.get("intend_industry_position", str())
            f_intend_school_program = request.json.get("intend_school_program", str())
            query = self.session.query(CdcBackgroundInfo).filter(CdcBackgroundInfo.f_sid == f_sid, CdcBackgroundInfo.id == f_background_info_id)
            obj = query.first()
            obj.f_graduate_plan = f_graduate_plan
            obj.f_internship_count = "N/A"
            obj.f_consult_count = "N/A"
            obj.f_activity_count = "N/A"
            obj.f_gre = f_gre
            obj.f_gmat = f_gmat
            obj.f_ielts = f_ielts
            obj.f_toefl = f_toefl
            obj.f_chinese_level = f_chinese_level
            obj.f_intend_area_study_employment = f_intend_area_study_employment
            obj.f_intend_industry_position = f_intend_industry_position
            obj.f_intend_school_program = f_intend_school_program
            self.session.commit()
            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": {},
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def detail_activity_info_search(self):
        try:
            f_uid = request.json.get("uid", str())
            f_sid = request.json.get("sid", str())
            f_record_id = request.json.get("record_id", str())
            f_page = request.json.get("page", str())
            f_limit = request.json.get("limit", str())
            query = self.session.query(CdcActivityInfo).filter(CdcActivityInfo.f_sid == f_sid)
            total = query.count()
            query = query.offset((int(f_page) - 1) * int(f_limit)).limit(int(f_limit))
            objs = query.all()
            res = list()
            for obj in objs:
                res.append({
                    "uid": f_uid,
                    "sid": str(obj.f_sid),
                    "record_id": f_record_id,
                    "activity_info_id": str(obj.id),
                    "activity_time": str(int(obj.f_activity_time.timestamp())) if obj.f_activity_time else "",
                    "activity_type": str(obj.f_activity_type),
                    "activity_name": str(obj.f_activity_name),
                    "remark": str(obj.f_remark),
                })
            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": {
                        "total": total,
                        "detail": res
                    },
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def detail_activity_info_template_download(self):
        try:
            return send_from_directory(
                os.path.join(current_app.root_path, "object/templates/ID_sme/cdc_career"),
                "活动信息-模板.xlsx",
                as_attachment=True,
                download_name="ActivityTemplate.xlsx"
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def detail_activity_info_cell_create(self):
        try:
            f_uid = request.json.get("uid", str())
            f_sid = request.json.get("sid", str())
            f_record_id = request.json.get("record_id", str())
            f_activity_time = request.json.get("activity_time", str())
            f_activity_type = request.json.get("activity_type", str())
            f_activity_name = request.json.get("activity_name", str())
            f_remark = request.json.get("remark", str())
            s_obj = self.session.query(CdcBaseInfo).filter(CdcBaseInfo.f_sid == f_sid).first()
            obj = CdcActivityInfo(
                f_sid=f_sid,
                f_activity_time=func.from_unixtime(f_activity_time),
                f_activity_type=f_activity_type,
                f_activity_name=f_activity_name,
                f_remark=f_remark,
                f_sid_id=s_obj.id
            )
            self.session.add(obj)
            self.session.commit()
            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": {
                        "activity_info_id": str(obj.id),
                    },
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def detail_activity_info_cell_search(self):
        try:
            f_uid = request.json.get("uid", str())
            f_sid = request.json.get("sid", str())
            f_record_id = request.json.get("record_id", str())
            f_activity_info_id = request.json.get("activity_info_id", str())
            query = self.session.query(CdcActivityInfo).filter(CdcActivityInfo.f_sid == f_sid)
            obj = query.first()
            res = dict()
            res["uid"] = f_uid
            res["sid"] = str(obj.f_sid)
            res["record_id"] = str(f_record_id)
            res["activity_info_id"] = str(obj.id)
            res["activity_time"] = str(int(obj.f_activity_time.timestamp())) if obj.f_activity_time else ""
            res["activity_type"] = str(obj.f_activity_type)
            res["activity_name"] = str(obj.f_activity_name)
            res["remark"] = str(obj.f_remark)
            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": res,
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def detail_activity_info_cell_update(self):
        try:
            f_uid = request.json.get("uid", str())
            f_sid = request.json.get("sid", str())
            f_record_id = request.json.get("record_id", str())
            f_activity_info_id = request.json.get("activity_info_id", str())
            f_activity_time = request.json.get("activity_time", str())
            f_activity_type = request.json.get("activity_type", str())
            f_activity_name = request.json.get("activity_name", str())
            f_remark = request.json.get("remark", str())
            query = self.session.query(CdcActivityInfo).filter(CdcActivityInfo.f_sid == f_sid, CdcActivityInfo.id == f_activity_info_id)
            obj = query.first()
            obj.f_activity_time = func.from_unixtime(f_activity_time)
            obj.f_activity_type = f_activity_type
            obj.f_activity_name = f_activity_name
            obj.f_remark = f_remark
            self.session.commit()
            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": {},
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def detail_activity_info_cell_delete(self):
        try:
            f_uid = request.json.get("uid", str())
            f_sid = request.json.get("sid", str())
            f_record_id = request.json.get("record_id", str())
            f_activity_info_id = request.json.get("activity_info_id", str())
            query = self.session.query(CdcActivityInfo).filter(CdcActivityInfo.f_sid == f_sid, CdcActivityInfo.id == f_activity_info_id)
            obj = query.first()
            self.session.delete(obj)
            self.session.commit()
            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": {},
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def detail_internship_info_search(self):
        try:
            f_uid = request.json.get("uid", str())
            f_sid = request.json.get("sid", str())
            f_record_id = request.json.get("record_id", str())
            f_page = request.json.get("page", str())
            f_limit = request.json.get("limit", str())
            query = self.session.query(CdcInternshipInfo).filter(CdcInternshipInfo.f_sid == f_sid)
            total = query.count()
            query = query.offset((int(f_page) - 1) * int(f_limit)).limit(int(f_limit))
            objs = query.all()
            res = list()
            for obj in objs:
                res.append({
                    "uid": f_uid,
                    "sid": str(obj.f_sid),
                    "record_id": str(f_record_id),
                    "internship_info_id": str(obj.id),
                    "start_time": str(int(obj.f_start_time.timestamp())) if obj.f_start_time else "",
                    "end_time": str(int(obj.f_end_time.timestamp())) if obj.f_end_time else "",
                    "internship_company": str(obj.f_company),
                    "internship_position": str(obj.f_position),
                    "internship_location": str(obj.f_location),
                })
            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": {
                        "total": total,
                        "detail": res
                    },
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def detail_internship_info_template_download(self):
        try:
            return send_from_directory(
                os.path.join(current_app.root_path, "object/templates/ID_sme/cdc_career"),
                "实习信息-模板.xlsx",
                as_attachment=True,
                download_name="InternshipTemplate.xlsx"
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def detail_internship_info_cell_create(self):
        try:
            f_uid = request.json.get("uid", str())
            f_sid = request.json.get("sid", str())
            f_record_id = request.json.get("record_id", str())
            f_start_time = request.json.get("start_time", datetime.datetime.now())
            f_end_time = request.json.get("start_time", datetime.datetime.now())
            f_company = request.json.get("company", str())
            f_position = request.json.get("position", str())
            f_location = request.json.get("location", str())

            s_obj = self.session.query(CdcBaseInfo).filter(CdcBaseInfo.f_sid == f_sid).first()
            obj = CdcInternshipInfo(
                f_sid = f_sid,
                f_start_time = func.from_unixtime(f_start_time),
                f_end_time = func.from_unixtime(f_end_time),
                f_company = f_company,
                f_position = f_position,
                f_location = f_location,
                f_sid_id = s_obj.id
            )
            self.session.add(obj)
            self.session.commit()
            self.session.flush()
            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": {
                        "offer_info_id": str(obj.id)
                    },
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def detail_internship_info_cell_search(self):
        try:
            f_uid = request.json.get("uid", str())
            f_sid = request.json.get("sid", str())
            f_record_id = request.json.get("record_id", str())
            f_internship_info_id = request.json.get("internship_info_id", str())
            query = self.session.query(CdcInternshipInfo).filter(CdcInternshipInfo.f_sid == f_sid)
            obj = query.first()
            res = dict()
            res["sid"] = str(obj.f_sid)
            res["internship_info_id"] = str(obj.id)
            res["start_time"] = str(int(obj.f_start_time.timestamp())) if obj.f_start_time else ""
            res["end_time"] = str(int(obj.f_start_time.timestamp())) if obj.f_end_time else ""
            res["internship_company"] = str(obj.f_company)
            res["internship_position"] = str(obj.f_position)
            res["internship_location"] = str(obj.f_location)
            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": res,
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def detail_internship_info_cell_update(self):
        try:
            f_uid = request.json.get("uid", str())
            f_sid = request.json.get("sid", str())
            f_record_id = request.json.get("record_id", str())
            f_internship_info_id = request.json.get("internship_info_id", str())
            f_start_time = request.json.get("start_time", str())
            f_end_time = request.json.get("end_time", str())
            f_internship_company = request.json.get("internship_company", str())
            f_internship_position = request.json.get("internship_position", str())
            f_internship_location = request.json.get("internship_location", str())
            query = self.session.query(CdcInternshipInfo).filter(CdcInternshipInfo.f_sid == f_sid, CdcInternshipInfo.id == f_internship_info_id)
            obj = query.first()
            obj.f_start_time = func.from_unixtime(f_start_time)
            obj.f_end_time = func.from_unixtime(f_end_time)
            obj.f_company = f_internship_company
            obj.f_position = f_internship_position
            obj.f_location = f_internship_location
            self.session.commit()
            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": {},
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def detail_internship_info_cell_delete(self):
        try:
            f_uid = request.json.get("uid", str())
            f_sid = request.json.get("sid", str())
            f_record_id = request.json.get("record_id", str())
            f_internship_info_id = request.json.get("internship_info_id", str())
            query = self.session.query(CdcInternshipInfo).filter(CdcInternshipInfo.f_sid == f_sid, CdcInternshipInfo.id == f_internship_info_id)
            obj = query.first()
            self.session.delete(obj)
            self.session.commit()
            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": {},
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def detail_offer_info_search(self):
        try:
            f_uid = request.json.get("uid", str())
            f_sid = request.json.get("sid", str())
            f_record_id = request.json.get("record_id", str())
            f_page = request.json.get("page", str())
            f_limit = request.json.get("limit", str())
            query = self.session.query(CdcOfferInfo).filter(CdcOfferInfo.f_sid == f_sid)
            total = query.count()
            query = query.offset((int(f_page) - 1) * int(f_limit)).limit(int(f_limit))
            objs = query.all()
            res = list()
            for obj in objs:
                res.append({
                    "sid": str(obj.f_sid),
                    "offer_info_id": str(obj.id),
                    "offer_type": str(obj.f_offer_type),
                    "offer_area": str(obj.f_offer_area),
                    "company_college_name": str(obj.f_company_college_name),
                    "position_project_name": str(obj.f_position_project_name),
                    "entrance_date": str(int(obj.f_entrance_date.timestamp())) if obj.f_entrance_date else "",
                    "industry_name": str(obj.f_industry_name),
                    "salary_month": str(obj.f_salary_month),
                    "salary_year": str(obj.f_salary_year),
                    "accept_status": str(obj.f_accept_status),
                    "remark": str(obj.f_remark),
                })
            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": {
                        "total": total,
                        "detail": res
                    },
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def detail_offer_info_cell_create(self):
        try:
            f_uid = request.json.get("uid", str())
            f_sid = request.json.get("sid", str())
            f_record_id = request.json.get("record_id", str())
            f_offer_type = request.json.get("offer_type", str())
            f_offer_area = request.json.get("offer_area", str())
            f_company_college_name = request.json.get("company_college_name", str())
            f_position_project_name = request.json.get("position_project_name", str())
            f_entrance_date = request.json.get("entrance_date", str())
            f_industry_name = request.json.get("industry_name", str())
            f_salary_month = request.json.get("salary_month", str())
            f_salary_year = request.json.get("salary_year", str())
            f_accept_status = request.json.get("accept_status", str())
            f_remark = request.json.get("remark", str())
            s_obj = self.session.query(CdcBaseInfo).filter(CdcBaseInfo.f_sid == f_sid).first()
            obj = CdcOfferInfo(
                f_sid=f_sid,
                f_offer_type=f_offer_type,
                f_offer_area=f_offer_area,
                f_company_college_name=f_company_college_name,
                f_position_project_name=f_position_project_name,
                f_entrance_date=f_entrance_date,
                f_industry_name=f_industry_name,
                f_salary_month=f_salary_month,
                f_salary_year=f_salary_year,
                f_accept_status=f_accept_status,
                f_remark=f_remark,
                f_sid_id=s_obj.id
            )
            self.session.add(obj)
            self.session.commit()
            self.session.flush()
            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": {
                        "offer_info_id": str(obj.id)
                    },
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def detail_offer_info_cell_search(self):
        try:
            f_uid = request.json.get("uid", str())
            f_sid = request.json.get("sid", str())
            f_record_id = request.json.get("record_id", str())
            f_offer_info_id = request.json.get("offer_info_id", str())
            query = self.session.query(CdcOfferInfo).filter(CdcOfferInfo.f_sid == f_sid)
            obj = query.first()
            res = dict()
            res["sid"] = str(obj.f_sid)
            res["offer_info_id"] = str(obj.id)
            res["offer_type"] = str(obj.f_offer_type)
            res["offer_area"] = str(obj.f_offer_area)
            res["college_name"] = str(obj.f_college_name)
            res["project_name"] = str(obj.f_project_name)
            res["project_type"] = str(obj.f_project_type)
            res["company_name"] = str(obj.f_company_name)
            res["position"] = str(obj.f_position)
            res["salary_month"] = str(obj.f_month_salary)
            res["salary_year"] = str(obj.f_year_salary)
            res["entrance_date"] = str(int(obj.f_entrance_date.timestamp())) if obj.f_entrance_date else ""
            res["entrance_year"] = str(obj.f_entrance_year)
            res["accept_status"] = str(obj.f_accept_status)
            res["remark"] = str(obj.f_remark)
            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": res,
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def detail_offer_info_cell_update(self):
        try:
            f_uid = request.json.get("uid", str())
            f_sid = request.json.get("sid", str())
            f_record_id = request.json.get("record_id", str())
            f_offer_info_id = request.json.get("offer_info_id", str())
            f_offer_type = request.json.get("offer_type", str())
            f_offer_area = request.json.get("offer_area", str())
            f_college_name = request.json.get("college_name", str())
            f_project_name = request.json.get("project_name", str())
            f_project_type = request.json.get("project_type", str())
            f_company_name = request.json.get("company_name", str())
            f_position = request.json.get("position", str())
            f_salary_month = request.json.get("salary_month", str())
            f_salary_year = request.json.get("salary_year", str())
            f_entrance_date = request.json.get("entrance_date", str())
            f_entrance_year = request.json.get("entrance_year", str())
            f_accept_status = request.json.get("accept_status", str())
            f_remark = request.json.get("remark", str())
            query = self.session.query(CdcOfferInfo).filter(CdcOfferInfo.f_sid == f_sid, CdcOfferInfo.id == f_offer_info_id)
            obj = query.first()
            obj.f_offer_type = f_offer_type
            obj.f_offer_area = f_offer_area
            obj.f_college_name = f_college_name
            obj.f_project_name = f_project_name
            obj.f_project_type = f_project_type
            obj.f_company_name = f_company_name
            obj.f_position = f_position
            obj.f_salary_month = f_salary_month
            obj.f_salary_year = f_salary_year
            obj.f_entrance_date = func.from_unixtime(f_entrance_date)
            obj.f_entrance_year = f_entrance_year
            obj.f_accept_status = f_accept_status
            obj.f_remark = f_remark
            self.session.commit()
            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": {},
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def detail_offer_info_cell_delete(self):
        try:
            f_uid = request.json.get("uid", str())
            f_sid = request.json.get("sid", str())
            f_record_id = request.json.get("record_id", str())
            f_offer_info_id = request.json.get("offer_info_id", str())
            query = self.session.query(CdcOfferInfo).filter(CdcOfferInfo.f_sid == f_sid, CdcOfferInfo.id == f_offer_info_id)
            obj = query.first()
            self.session.delete(obj)
            self.session.commit()
            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": {},
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def detail_offer_info_download(self):
        try:
            f_uid = request.json.get("uid", str())
            f_sid = request.json.get("sid", str())
            f_record_id = request.json.get("record_id", str())
            query = self.session.query(CdcOfferInfo).filter(CdcOfferInfo.f_sid == f_sid)
            objs = query.all()
            res = list()
            seq = 0
            for obj in objs:
                seq += 1
                res.append({
                    "seq": str(seq),
                    "sid": str(obj.f_sid),
                    "offer_type": str(obj.f_offer_type),
                    "offer_area": str(obj.f_offer_area),
                    "college_name": str(obj.f_college_name),
                    "project_name": str(obj.f_project_name),
                    "project_type": str(obj.f_project_type),
                    "company_name": str(obj.f_company_name),
                    "position": str(obj.f_position),
                    "month_salary": str(obj.f_month_salary),
                    "year_salary": str(obj.f_year_salary),
                    "entrance_date": str(int(obj.f_entrance_date.timestamp())) if obj.f_entrance_date else "",
                    "entrance_year": str(obj.f_entrance_year),
                    "accept_status": str(obj.f_accept_status)
                })
            df = pd.DataFrame(res)
            output = BytesIO()
            with pd.ExcelWriter(output, engine="xlsxwriter") as writer:
                df.to_excel(writer, sheet_name="Download", index=False)
            output.seek(0)
            return send_file(output, as_attachment=True, mimetype="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", download_name="Export.xlsx")
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def detail_offer_info_template_download(self):
        try:
            return send_from_directory(
                os.path.join(current_app.root_path, "object/templates/ID_sme/cdc_career"),
                "Offer信息-模板.xlsx",
                as_attachment=True,
                download_name="OfferTemplate.xlsx"
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def detail_offer_info_school_fuzzy(self):
        try:
            f_query_key = request.json.get("query_key", str())
            query = self.session.query(CdcSchoolProgramArea).filter(CdcSchoolProgramArea.f_school.ilike(f'%{f_query_key}%'))
            objs = query.all()
            res = list()
            for obj in objs:
                res.append(obj.f_school)
            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": res,
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def detail_offer_info_program_fuzzy(self):
        try:
            f_query_key = request.json.get("query_key", str())
            query = self.session.query(CdcSchoolProgramArea).filter(CdcSchoolProgramArea.f_program.ilike(f'%{f_query_key}%'))
            objs = query.all()
            res = list()
            for obj in objs:
                res.append(obj.f_program)
            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": res,
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def detail_offer_info_area_fuzzy(self):
        try:
            f_query_key = request.json.get("query_key", str())
            query = self.session.query(CdcSchoolProgramArea).filter(CdcSchoolProgramArea.f_area.ilike(f'%{f_query_key}%'))
            objs = query.all()
            res = list()
            for obj in objs:
                res.append(obj.f_area)
            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": res,
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def detail_key_info_search(self):
        try:
            f_uid = request.json.get("uid", str())
            f_sid = request.json.get("sid", str())
            f_record_id = request.json.get("record_id", str())
            f_key_info_id = request.json.get("key_info_id", str())
            res = dict()
            query = self.session.query(CdcKeyInfo).filter(CdcKeyInfo.f_sid == f_sid)
            obj = query.first()
            res["sid"] = str(obj.f_sid)
            res["key_info_id"] = str(obj.id)
            res["apecial_attention"] = str(obj.f_apecial_attention)
            res["difficulty_type"] = str(obj.f_difficulty_type)
            res["support_need"] = str(obj.f_support_need)
            res["support_info"] = str(obj.f_support_info)
            res["parents_contacted"] = str(obj.f_parents_contacted)

            query = self.session.query(CdcGraduateInfo).filter(CdcGraduateInfo.f_sid == f_sid)
            obj = query.first()
            res["province_system_report"] = str(obj.f_province_system_report)
            res["graduate_registe_report"] = str(obj.f_graduate_registe_report)

            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": res,
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def detail_key_info_update(self):
        try:
            f_uid = request.json.get("uid", str())
            f_sid = request.json.get("sid", str())
            f_record_id = request.json.get("record_id", str())
            f_key_info_id = request.json.get("key_info_id", str())
            f_apecial_attention = request.json.get("special_attention", str())
            f_difficulty_type = request.json.get("difficulty_type", str())
            f_support_need = request.json.get("support_need", str())
            f_support_info = request.json.get("support_info", str())
            f_parents_contacted = request.json.get("parents_contacted", str())
            f_graduate_registe_report = request.json.get("graduate_registe_report", str())
            f_province_system_report = request.json.get("province_system_report", str())

            query = self.session.query(CdcKeyInfo).filter(CdcKeyInfo.f_sid == f_sid)
            obj = query.first()
            obj.f_apecial_attention = f_apecial_attention
            obj.f_difficulty_type = f_difficulty_type
            obj.f_support_need = f_support_need
            obj.f_support_info = f_support_info
            obj.f_parents_contacted = f_parents_contacted
            self.session.commit()

            query = self.session.query(CdcGraduateInfo).filter(CdcGraduateInfo.f_sid == f_sid)
            obj = query.first()
            obj.f_province_system_report = f_province_system_report
            obj.f_graduate_registe_report = f_graduate_registe_report
            self.session.commit()

            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": {},
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def detail_graduate_info_search(self):
        try:
            f_uid = request.json.get("uid", str())
            f_sid = request.json.get("sid", str())
            f_record_id = request.json.get("record_id", str())
            f_graduate_info_id = request.json.get("graduate_info_id", str())
            query = self.session.query(CdcGraduateInfo).filter(CdcGraduateInfo.f_sid == f_sid)
            obj = query.first()
            res = dict()
            res["sid"] = str(obj.f_sid)
            res["graduate_info_id"] = str(obj.id)
            res["province_system_report"] = str(obj.f_province_system_report)
            res["graduate_registe_report"] = str(obj.f_graduate_registe_report)
            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": res,
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def detail_graduate_info_update(self):
        try:
            f_uid = request.json.get("uid", str())
            f_sid = request.json.get("sid", str())
            f_record_id = request.json.get("record_id", str())
            f_graduate_info_id = request.json.get("graduate_info_id", str())
            f_province_system_report = request.json.get("province_system_report", str())
            f_graduate_registe_report = request.json.get("graduate_registe_report", str())
            query = self.session.query(CdcGraduateInfo).filter(CdcGraduateInfo.f_sid == f_sid, CdcGraduateInfo.id == f_graduate_info_id)
            obj = query.first()
            obj.f_province_system_report = f_province_system_report
            obj.f_graduate_registe_report = f_graduate_registe_report
            self.session.commit()
            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": {},
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def detail_recommend_info_search(self):
        try:
            # TODO: 待实现
            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": {
                        "recommend_school": "宾夕法尼亚大学"
                    },
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def detail_daily_info_search(self):
        try:
            f_uid = request.json.get("uid", str())
            f_sid = request.json.get("sid", str())
            f_record_id = request.json.get("record_id", str())
            f_page = request.json.get("page", str())
            f_limit = request.json.get("limit", str())
            query = self.session.query(CdcDailyInfo).filter(CdcDailyInfo.f_sid == f_sid)
            total = query.count()
            query = query.offset((int(f_page) - 1) * int(f_limit)).limit(int(f_limit))
            objs = query.all()
            res = list()
            for obj in objs:
                res.append({
                    "sid": str(obj.f_sid),
                    "daily_info_id": str(obj.id),
                    "daily_record_name": str(obj.f_name),
                    "daily_record_type": str(obj.f_type),
                    "daily_record_time": str(int(obj.f_time.timestamp())) if obj.f_time else "",
                    "daily_record_detail": str(obj.f_detail)
                })
            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": {
                        "total": total,
                        "detail": res
                    },
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def detail_daily_info_template_download(self):
        try:
            return send_from_directory(
                os.path.join(current_app.root_path, "object/templates/ID_sme/cdc_career"),
                "CDC记录-模板.xlsx",
                as_attachment=True,
                download_name="DailyTemplate.xlsx"
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def detail_daily_info_cell_create(self):
        try:
            f_uid = request.json.get("uid", str())
            f_sid = request.json.get("sid", str())
            f_record_id = request.json.get("record_id", str())
            f_record_name = request.json.get("record_name", str())
            f_record_type = request.json.get("record_type", str())
            f_record_time = request.json.get("record_time", str())
            f_record_detail = request.json.get("record_detail", str())
            s_obj = self.session.query(CdcBaseInfo).filter(CdcBaseInfo.f_sid == f_sid).first()
            obj = CdcDailyInfo(
                f_sid=f_sid,
                f_name=f_record_name,
                f_type=f_record_type,
                f_time=func.from_unixtime(f_record_time),
                f_detail=f_record_detail,
                f_sid_id=s_obj.id
            )
            self.session.add(obj)
            self.session.commit()
            self.session.flush()
            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": {
                        "daily_info_id": str(obj.id)
                    },
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def detail_daily_info_cell_search(self):
        try:
            f_uid = request.json.get("uid", str())
            f_sid = request.json.get("sid", str())
            f_record_id = request.json.get("record_id", str())
            f_daily_info_id = request.json.get("daily_info_id", str())
            query = self.session.query(CdcDailyInfo).filter(CdcDailyInfo.f_sid == f_sid, CdcDailyInfo.id == f_daily_info_id)
            obj = query.first()
            res = dict()
            res["sid"] = str(obj.f_sid)
            res["daily_info_id"] = str(obj.id)
            res["daily_record_name"] = str(obj.f_name)
            res["daily_record_type"] = str(obj.f_type)
            res["daily_record_time"] = str(int(obj.f_time.timestamp())) if obj.f_time else ""
            res["daily_record_detail"] = str(obj.f_detail)
            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": res,
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def detail_daily_info_cell_update(self):
        try:
            f_uid = request.json.get("uid", str())
            f_sid = request.json.get("sid", str())
            f_record_id = request.json.get("record_id", str())
            f_daily_info_id = request.json.get("daily_info_id", str())
            f_record_name = request.json.get("record_name", str())
            f_record_type = request.json.get("record_type", str())
            f_record_time = request.json.get("record_time", str())
            f_record_detail = request.json.get("record_detail", str())
            query = self.session.query(CdcDailyInfo).filter(CdcDailyInfo.f_sid == f_sid, CdcDailyInfo.id == f_daily_info_id)
            obj = query.first()
            obj.f_name = f_record_name
            obj.f_type = f_record_type
            obj.f_time = func.from_unixtime(f_record_time)
            obj.f_detail = f_record_detail
            self.session.commit()
            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": {},
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def detail_daily_info_cell_delete(self):
        try:
            f_uid = request.json.get("uid", str())
            f_sid = request.json.get("sid", str())
            f_record_id = request.json.get("record_id", str())
            f_daily_info_id = request.json.get("daily_info_id", str())
            query = self.session.query(CdcDailyInfo).filter(CdcDailyInfo.f_sid == f_sid, CdcDailyInfo.id == f_daily_info_id)
            obj = query.first()
            self.session.delete(obj)
            self.session.commit()
            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": {},
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def box_graduate_plan_search(self):
        try:
            query = self.session.query(CdcIsGraduatePlan)
            objs = query.all()
            res = list()
            for obj in objs:
                res.append(obj.f_value)
            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": res,
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def box_offer_type_search(self):
        try:
            query = self.session.query(CdcIsOfferType)
            objs = query.all()
            res = list()
            for obj in objs:
                res.append(obj.f_value)
            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": res
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def box_chinese_level_search(self):
        try:
            query = self.session.query(CdcIsChineseLevel)
            objs = query.all()
            res = list()
            for obj in objs:
                res.append(obj.f_value)
            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": res
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def box_project_type_search(self):
        try:
            query = self.session.query(CdcIsProjectType)
            objs = query.all()
            res = list()
            for obj in objs:
                res.append(obj.f_value)
            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": res
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def box_entrance_year_search(self):
        try:
            query = self.session.query(CdcIsEntranceYear)
            objs = query.all()
            res = list()
            for obj in objs:
                res.append(obj.f_value)
            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": res
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def box_offer_status_search(self):
        try:
            query = self.session.query(CdcIsOfferState)
            objs = query.all()
            res = list()
            for obj in objs:
                res.append(obj.f_value)
            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": res
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def box_difficulty_type_search(self):
        try:
            query = self.session.query(CdcIsDifficultyType)
            objs = query.all()
            res = list()
            for obj in objs:
                res.append(obj.f_value)
            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": res
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def box_apecial_attention_search(self):
        try:
            query = self.session.query(CdcIsApecialAttention)
            objs = query.all()
            res = list()
            for obj in objs:
                res.append(obj.f_value)
            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": res
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def box_parents_contacted_search(self):
        try:
            query = self.session.query(CdcIsParentsContacted)
            objs = query.all()
            res = list()
            for obj in objs:
                res.append(obj.f_value)
            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": res
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def box_province_system_report_search(self):
        try:
            query = self.session.query(CdcIsProvinceSystemReport)
            objs = query.all()
            res = list()
            for obj in objs:
                res.append(obj.f_value)
            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": res
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def box_graduate_registe_report_search(self):
        try:
            query = self.session.query(CdcIsGraduateRegisteReport)
            objs = query.all()
            res = list()
            for obj in objs:
                res.append(obj.f_value)
            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": res
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def box_recommend_area_search(self):
        try:
            # TODO: 待实现
            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": ["中国", "美国", "英国", "日本", "法国", "德国", "韩国", "新加坡", "马来西亚", "比利时", "荷兰", "西班牙", "意大利", "澳大利亚", "新西兰", "印度", "泰国", "俄罗斯", "土耳其", "沙特阿拉伯", "阿联酋", "伊朗", "埃及", "越南", "菲律宾", "印度尼西亚", "巴基斯坦", "缅甸", "柬埔寨", ]
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def access_list_search(self):
        try:
            query = self.session.query(CdcAccessInfo)
            objs = query.all()
            res = list()
            for obj in objs:
                res.append({
                    "access_id": str(obj.f_access_id),
                    "access_name": str(obj.f_access_name),
                })
            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": res,
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def access_user_info_search(self):
        try:
            f_uid = request.json.get("uid", str())
            f_page = request.json.get("page", 1)
            f_limit = request.json.get("limit", 10)
            query = self.session.query(CdcUserInfo).filter(CdcUserInfo.f_access_id != "1")
            total = query.count()
            query = query.offset((int(f_page) - 1) * int(f_limit)).limit(int(f_limit))
            objs = query.all()
            res = list()
            for obj in objs:
                res.append({
                    "uid": str(f_uid),
                    "user_id": str(obj.id),
                    "access_id": str(obj.f_access_id),
                    "user_name": str(obj.f_username),
                    "access_name": str(obj.f_access_name),
                })
            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": {
                        "total": total,
                        "detail": res
                    },
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def access_user_info_update(self):
        try:
            f_uid = request.json.get("uid", str())
            f_user_id = request.json.get("user_id", str())
            f_access_id = request.json.get("access_id", str())
            f_access_name = request.json.get("access_name", str())
            query = self.session.query(CdcUserInfo).filter(CdcUserInfo.id == f_user_id)
            obj = query.first()
            obj.f_access_id = f_access_id
            obj.f_access_name = f_access_name
            self.session.commit()
            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": {},
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def detail_resume_info_upload(self):
        try:
            f_uid = request.form.get("uid", str())
            f_sid = request.form.get("sid", str())
            f_record_id = request.form.get("record_id", str())
            if "file" not in request.files:
                return jsonify({"code": 400, "msg": "未上传文件", "data": {}})
            file = request.files["file"]
            if file.filename == "":
                return jsonify({"code": 400, "msg": "未选择文件", "data": {}})
            file_path = "/".join([self.resume_path, f_sid, file.filename])
            if not os.path.exists(os.path.dirname(file_path)):
                os.makedirs(os.path.dirname(file_path))
            file.save(file_path)
            s_obj = self.session.query(CdcBaseInfo).filter(CdcBaseInfo.f_sid == f_sid).first()
            obj = CdcResumeInfo(
                f_sid=f_sid,
                f_resume_name=file.filename,
                f_resume_path=file_path,
                f_resume_data=b"N/A",
                f_sid_id=s_obj.id
            )
            self.session.add(obj)
            self.session.commit()
            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": {
                        "file_name": file.filename
                    }
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def detail_resume_info_delete(self):
        try:
            f_uid = request.json.get("uid", str())
            f_sid = request.json.get("sid", str())
            f_record_id = request.json.get("record_id", str())
            f_resume_id = request.json.get("resume_id", str())
            query = self.session.query(CdcResumeInfo).filter(CdcResumeInfo.f_sid == f_sid, f_resume_id == f_resume_id)
            obj = query.first()
            if obj is not None:
                self.session.delete(obj)
                self.session.commit()
            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": dict()
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def detail_resume_info_search(self):
        try:
            f_uid = request.json.get("uid", str())
            f_sid = request.json.get("sid", str())
            f_record_id = request.json.get("record_id", str())
            query = self.session.query(CdcResumeInfo).filter(CdcResumeInfo.f_sid == f_sid)
            objs = query.all()
            res = list()
            for obj in objs:
                res.append({
                    "resume_id": str(obj.id),
                    "resume_name": str(obj.f_resume_name),
                })
            return jsonify(
                {
                    "code": 200,
                    "msg": "success",
                    "data": res
                }
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})

    def detail_resume_info_download(self):
        try:
            f_uid = request.json.get("uid", str())
            f_sid = request.json.get("sid", str())
            f_record_id = request.json.get("record_id", str())
            f_resume_id = request.json.get("resume_id", str())
            query = self.session.query(CdcResumeInfo).filter(CdcResumeInfo.f_sid == f_sid, CdcResumeInfo.id == f_resume_id)
            obj = query.first()
            resume_name = obj.f_resume_name
            resume_data = obj.f_resume_data
            output = BytesIO(resume_data)
            output.seek(0)
            return send_file(
                output,
                as_attachment=True,
                download_name=resume_name,
                mimetype='application/octet-stream'
            )
        except Exception as e:
            self.logger.error(f"[{request.request_id}] {e}")
            self.session.rollback()
            return jsonify({"code": 500, "msg": "服务器错误", "data": {}})
